﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<script>
    var data = unescape($.request("data"));
    $(function () {
        initControl();
        gridList();
    });
    function initControl() {
        var myLayout = $('#layout').layout({ resizable: false });
        $('select').bindSelect();
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/VBaseData/V_Sys_User/GetUserInfos",
            height: 260,
            colModel: [
                { label: '<input id="selectAll" type="checkbox" style="text-align:center;">', width: 36, align: 'center', sortable: false, formatter: $.checkbox, unformat: $.empty },
                { label: '人员编码', name: 'F_Account', width: 80, align: 'center' },
                { label: '人员名称', name: 'F_RealName', width: 120, align: 'center' },
                { label: '使用单位', name: 'F_OrganizeName', width: 80, align: 'center' },
                { label: '部门科室', name: 'F_DepartmentName', width: 80, align: 'center' },
                { label: '工作岗位', name: 'F_DutyName', width: 80, align: 'center' }
            ],
            pager: "#gridPager",
            sortname: 'F_Account asc',
            viewrecords: true,
            gridComplete: function () {
                if (data != "")
                {
                    var dataArr = data.split(',');
                    $.each(dataArr, function (index,item) {
                        $("#gridList").find('[title="' + item + '"]').each(function () {
                            $(this).parent().find("input[type=checkbox]").prop("checked", true);
                        });
                    });
                }
                btn_plus();
            }
        });
    }

    function btn_ok() {
        parent.getData(GetData());
        parent.$.detailClose();
    }

    function btn_cancel() {
        parent.$.detailClose();
    }
    function btn_plus() {
        $("#txtSelectValues").val(GetData());
    }
    function GetData() {
        var dataArr = [];
        $("#gridList input:checkbox:checked").each(function () {
            var rowid = $(this).attr("value");
            dataArr.push($("#gridList").jqGrid('getRowData', rowid).F_RealName);
        });
        return dataArr.join(",");
    }
    function Query() {
        $("#gridList").jqGrid('setGridParam', {
            postData: { IdorName: $("#txtIdOrName").val()}
        }).trigger('reloadGrid');
    }
</script>
<div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
    <div class="ui-layout-center">
        <form id="form1">
            <div style="padding: 5px 0; padding-left:15px; margin-right: 30px;" class="line-table input-width-140">
                <label class="prefix">查询人员</label> 
                <input id="txtIdOrName"  type="text" class="form-control" />
                &nbsp;
                <div class="btn-group" style="margin-top:-1px;">
                    <a id="" class="btn btn-primary center-block btn-1" onclick="Query()"><span class="glyphicon glyphicon-ok"></span> 查询</a>
                </div>
            </div>
            <div style="border-bottom:1px solid #ccc;">
                <table id="gridList"></table>
            </div> 
            <div style="padding: 5px 0; padding-left:15px; margin-right: 30px;" class="line-table">
                <label class="prefix">已选择人员</label>
                <input id="txtSelectValues"  type="text" class="form-control" />
                <div style="text-align:right;padding-right:30px;padding-top:10px;">
                    <div class="btn-group" style="margin-right:20px;">
                        <a id="" class="btn btn-primary center-block" onclick="btn_plus()"><span class="glyphicon glyphicon-plus"></span> 选择</a>
                    </div>
                    <div class="btn-group" style="margin-right:20px;">
                        <a id="" class="btn btn-primary center-block" onclick="btn_ok()"><span class="glyphicon glyphicon-ok"></span> 确认</a>
                    </div>
                    <div class="btn-group">
                        <a id="" class="btn btn-primary center-block" onclick="btn_cancel()"><span class="glyphicon glyphicon-remove"></span> 取消</a>
                    </div>
                </div>
            </div>
        </form>    
    </div>

</div>

